"""自定义TestCase,继承后减少代码量"""
import unittest
from utils import get_date, get_driver, parameter
from login import Login
from config import get_cfg
import time


class MyTestCase(unittest.TestCase):
    driver = None

    @classmethod
    def setUpClass(cls) -> None:
        base_url = get_cfg('url', 'base_url')
        cls.driver = get_driver()
        print(cls.driver, 'MyTestCase')
        parameter['driver'] = cls.driver
        cls.driver.get(base_url + 'Login.html')
        cls.driver.set_window_size(1920, 1080)
        cls.driver.maximize_window()
        # cls.driver.execute_script(js)
        # cls.driver.get(base_url + 'Index.html')
        cls.driver.implicitly_wait(30)
        Login(cls.driver).user_login()
        cls.faker = Login(cls.driver).faker

        # 今天
        cls.today = get_date(1)
        # 明天
        cls.tomorrow = get_date(2)
        # 后天
        cls.the_day_after_tomorrow = get_date(3)
        # 昨天
        cls.yesterday = get_date(0)

    @classmethod
    def tearDownClass(cls) -> None:
        time.sleep(1)
        cls.driver.quit()
